﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodWorx.Core.DomainModel;
using System.Xml.Serialization;

namespace MethodWorx.CMS.Workflow
{
    [Serializable]
    public class WorkflowConfigurationStep : Entity
    {
        public WorkflowConfigurationStep()
        {
            this.CanConfigure = true;
        }

        public WorkflowConfigurationStep[] Steps { get; set; }
        public Guid ComponentId { get; set; }
        [XmlIgnore]
        public IWorkflowConfiguration ComponentConfiguration { get; set; }
        public string Name { get; set; }
        public bool CanConfigure { get; set; }
        public string Output { get; set; }
        public string OutputType { get; set; }

        public string SerializedConfiguration
        {
            get
            {
                if (this.ComponentConfiguration == null)
                    return null;
                else
                {
                    return this.ComponentConfiguration.Base64SerializeUsingXml();
                }
            }
            set
            {
                if (!string.IsNullOrEmpty(value))
                {
                    this.ComponentConfiguration = (IWorkflowConfiguration)value.Base64DeserializeUsingXml();
                }
            }
        }
    }
}
